home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok15.lha
/
Seafarers_Manual
/
Source
/
Pendulum.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
1KB
|
51 lines
MODULE Pendulum; (* Calculate velocity & acceleration of
swinging pendulum *)
(* From the book "Modula-2 A Seafarer's Manual and Shipyard Guide" *)
(* Page 37 adapted "Amiga M2Modula-2" 21 Feb 1988 *)
FROM InOut IMPORT WriteLn,
WriteString;
FROM RealInOut IMPORT WriteReal,
ReadReal;
FROM MathLib0 IMPORT sin,
cos;
CONST
fieldwidth = 10; (* width of output field *)
decimaldigit = 8; (* number of output decimal digits *)
VAR
r, (* input-pendulum length *)
w, (* angular velocity *)
t, (* time *)
velocity, (* velocity result *)
acceleration : REAL; (* acceleration result *)
BEGIN
WriteLn;
WriteString ("Enter pedulum length: ");
ReadReal (r); (* get length from keyboard *)
WriteLn;
WriteString ("Enter angular velocity: ");
ReadReal (w); (* get velocity from keyboard *)
WriteLn;
WriteString ("Enter time: ");
ReadReal (t); (* get time from keyboard *)
velocity := (r * w) * (cos(w * t));
acceleration := (r * (w * w)) * (sin(w * t));
WriteLn;
WriteString ("Velocity = ");
WriteReal (velocity,fieldwidth,decimaldigit);
WriteLn;
WriteString ("Acceleration = ");
WriteReal (acceleration,fieldwidth, decimaldigit);
WriteLn;
END Pendulum.